<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>[[${sjcd}]]-[[${ejcd}]] - [[${T(com.b2c.erp.DataConfigObject).getInstance().getSysName()}]]</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;top: 0px;">

    <!-- start sp-wrapper -->
    <link rel="stylesheet" href="/sb/stock.css"/>
    <div class="sp-wrapper">
        <h2 class="sp-title"><span th:text="${sjcd}"></span></h2>
        <div class="sp-tool">
            <span class="fl">
                <form action="/stock_in/purchase_in_wait_list" method="get">
                <b><input type="text" name="billNo" th:value="${billNo}" placeholder="输入单据编号查询" style="width:200px;"></b>
                <b>单据日期：
                    <input type="text" name="startDate" autocomplete="off" style="width: 120px" th:value="${startDate}" class="startDate"> -
                    <input type="text" th:value="${endDate}" name="endDate" class="endDate" style="width: 120px" autocomplete="off">
                    <input type="submit" class="button" value="查询"></b>
                    <b>总共：&nbsp;[[${totalSize}]]&nbsp;条记录</b>
                </form>

            </span>


        </div>
        <div class="sp-table">

            <table>
                <thead>
                <tr>
                    <th>采购单ID</th>
                    <th>单据日期</th>
                    <th>单据编号</th>
                    <th>合同号</th>
                    <th>供应商</th>
                    <th>采购总数</th>
                    <th>已入库数量</th>
                    <th>总金额</th>
                    <!--<th>购货金额</th>-->
                    <!--<th>优惠后金额</th>-->
                    <!--<th>已付款</th>-->
<!--                    <th>付款状态</th>-->
                    <!--<th>数量</th>-->
                    <th>制单人</th>
<!--                    <th>审核人</th>-->
                    <th>状态</th>
                    <th>备注</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="sp-data">
                <tr th:each="item:${list}">
                    <td th:text="${item.id}">2019-03-15</td>
                    <td th:text="${item.billDate}">2019-03-15</td>
                    <td th:text="${item.billNo}">CG201903121700193</td>
                    <td th:text="${item.contractNo}">CG201903121700193</td>
                    <td th:text="${item.contactName}">华衣</td>
                    <td th:text="${item.totalQuantity}">0</td>
                    <td th:text="${item.inQuantity}">0</td>
                    <td th:text="${#numbers.formatDecimal(item.totalAmount, 1, 2)}">0</td>
                    <!--<td th:text="${#numbers.formatDecimal(item.totalAmount, 1, 2)}">1000.00</td>-->
                    <!--<td th:text="${#numbers.formatDecimal(item.amount, 1, 2)}">900.00</td>-->
                    <!--<td th:text="${#numbers.formatDecimal(item.rpAmount, 1, 2)}">500.00</td>-->
<!--                    <td th:switch="${item.rpAmount}">-->
<!--                        <b th:case="0">未付款</b>-->
<!--                        <b th:case="item.amount">已付款</b>-->
<!--                        <b th:case="*">部分付款</b>-->
<!--                    </td>-->
                    <!--<td th:text="${item.totalQuantity}">500</td>-->
                    <td th:text="${item.userName}">华衣</td>
<!--                    <td th:text="${item.checkName}">华衣</td>-->
                    <td th:text="${T(com.b2c.entity.erp.enums.InvoiceBillStatusEnum).getName(item.billStatus)}">华衣</td>
                    <td th:text="${item.description}">收到货请检查</td>
                    <td>
                        <!--<i class="print" th:attr="data-id=${item.id}">打印</i>-->
                      <a th:href="${'/purchase/detail?id='+item.id}" target="_blank">详情</a>
<!--                        <i class="delete" th:attr="data-id=${item.id}">删除</i>-->
                        <!--<a th:href="@{/purchase/checkout_form(id=${item.id})}">验货</a>-->
                        <a th:href="@{/purchase/stock_in(id=${item.id})}" th:if="${item.checked == 1 && item.billStatus == 1}" target="_blank">入库</a>
<!--                        <a th:href="@{/stock_in/purchase_in_list(billNo=${item.billNo})}" >入库记录1</a>-->
                        <a th:href="@{/stock_in/stock_in_form_list(type=1,iid=${item.id})}" >入库记录</a>
                        <!--<a target="_blank" th:href="@{/purchase/purchase_cancel(id=${item.id})}">采购退货</a>-->
                    </td>
                </tr>

                </tbody>
            </table>

        </div>
        <div class="pages">
            <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
        </div>
    </div>

    <script type="text/javascript" src="/sb/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>
  <!--  <script type="text/javascript">
        $(function () {
            // 删除
            $('.delete').click(function () {
                var obj = $(this).parent().parent();
                var id = $(this).attr('data-id');
                Tips.confirm({
                    title: '删除记录',
                    content: '您确定要删除该购货记录吗？',
                    define: function () {

                        // ajax处理invoice_delete
                        $.ajax({
                            url: "/ajax_purchase/invoice_delete",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json",
                            data: JSON.stringify({id: id}),
                            success: function (res) {
                                // alert(res.data.length);
                                if (res.code == 0) {
                                    Tips.alert('删除成功', function () {
                                        // location.reload(true);
                                        $(obj).remove();
                                    });

                                }
                                // alert(JSON.stringify(res));
                            }
                        });

                        // .. id
                        // Tips.alert('删除成功', function () {
                        //     location.reload(true);
                        // });
                    }
                });
            });


        });
    </script>-->



    <!-- end sp-wrapper -->
    <script>
        layui.use(['laydate', 'layer'], function () {
            var laydate = layui.laydate;
            var layer = layui.layer;
            //执行一个laydate实例
            laydate.render({
                elem: '.startDate' //指定元素
            });
            laydate.render({
                elem: '.endDate' //指定元素
            });


            $(".print").click(function () {
                var id = $(this).attr("data-id");
                console.log(id);
                //iframe层

                layer.open({
                    type: 2,
                    title: '打印采购单',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['940px', '90%'],
                    content: '/purchase/detail?id=' + id //iframe的url
                });
            })

        });
    </script>
</div>
</body>
<html>
